{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<!-- （勿改动，执行即可）执行更改背景 -->\n",
       "<link rel=\"stylesheet\" href=\"exam.css\" type=\"text/css\">\n",
       "<h1 style=\"color: red;\">注意单元格的第一行不能改动，否则会影响自动打分</h1>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%%html\n",
    "<!-- （勿改动，执行即可）执行更改背景 -->\n",
    "<link rel=\"stylesheet\" href=\"exam.css\" type=\"text/css\">\n",
    "<h1 style=\"color: red;\">注意单元格的第一行不能改动，否则会影响自动打分</h1>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "# Big Data期末考（A卷）：目前工作目录C:\\Users\\nfulab\n",
       "* 共6题，每题20分，80分及格，最高分120，作题时间60分钟。\n",
       "*  答题格首行如 ***# 003*** 勿删除或改动 \n",
       "* 可先挑难度较易的题先做，🌶个数愈高愈难\n",
       "* 执行一格格，最後一格可回报分数（仅供参考）\n",
       " ##提交此.ipynb档，必檢查： \n",
       "   * 档名✍A_学号✍（只能用半角数字9碼）\n",
       "   *  下格 输入学号（半角数字9碼） \n",
       "\n",
       "\n",
       "# 🛂输入学号🛂"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 始000（勿改动，执行即可）\n",
    "e = %env\n",
    "_which_= \"A\"  # 卷號\n",
    "import PandasCourse as PC\n",
    "from IPython.display import Markdown\n",
    "Markdown(PC.msgs['opening'].format(w=_which_, d=e['HOMEDRIVE']+ e['HOMEPATH']))    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 始001（✍請改动並执行）\n",
    "student_id = \"\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 读入数据\n",
    "* 以下代码是读入相关文本数据\n",
    "* 所有文本数据赋值给text\n",
    "* 以下考题皆为针对此text做相关操作"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "df = pd.read_excel('02_df_content.xlsx')\n",
    "text = \"\".join(list(df.cleaned)) "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Q1（20分） 🌶 易\n",
    "* 查找\"新媒体\"的次数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "155"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "phrase = \"新媒体\"\n",
    "freq_table_phrase=text.count(phrase)\n",
    "freq_table_phrase"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Q2（20分） 🌶 易\n",
    "* 用中文\"。\"拆分,生成list_split列表，每一个句子是一个独立的列表元素"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "list_split =✍\n",
    "list_split"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Q3 （20分） 🌶 易\n",
    "* 取出第十个句子"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "✍"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Q4 （20分） 🌶🌶  中\n",
    "* 请找出text中所有\"传播\"关键字前面的两个字符"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "答案提示：['融媒', '题式', '互式', ... '能和', '当下', '二次']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "phrase=\"传播\"\n",
    "\n",
    "position_all=[]\n",
    "✍\n",
    "...\n",
    "✍\n",
    "content_all=[]\n",
    "✍\n",
    "...\n",
    "✍\n",
    "    \n",
    "print(content_all)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Q5 （20分） 🌶🌶  中\n",
    "* 统计text中所有\"传播\"关键字前面的两个字符的次数"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "{'融媒': 20, '题式': 1, '互式': 3,... '能新': 1, '全域': 1, '能和': 1, '当下': 1}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "found = {}\n",
    "✍\n",
    "...\n",
    "✍\n",
    "print(found)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Q6 （20分） 🌶 🌶 🌶 稍难\n",
    "* 找出text中所有\"传播\"关键字前面的两个字符的次数排在前五的关键词，作为一个新的字典输出"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "found_ext_rev = ✍\n",
    "top5_found=✍\n",
    "print(top5_found)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'总分': 20, 'details': {'freq_table_phrase': 20}}\n"
     ]
    }
   ],
   "source": [
    "#终001 （勿改动，执行即可）回报答题分数\n",
    "import PandasCourse as PC\n",
    "\n",
    "score_details = PC.score_answers(locals(), _which_)\n",
    "print (score_details[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
